package com.example.pt.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.pt.dto.TorrentSeedInfoDTO;
import com.example.pt.entity.TorrentSeedStats;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface TorrentSeedStatsMapper extends BaseMapper<TorrentSeedStats> {
    /**
     * 根据种子ID查询做种信息
     * @param tid 种子ID
     * @return 种子做种信息DTO
     */
    @Select("SELECT t.tid, t.title, tss.seeders, tss.leechers, tss.last_updated as lastUpdated " +
            "FROM torrentFile t " +
            "LEFT JOIN torrent_info_hash tih ON t.tid = tih.tid " +
            "LEFT JOIN torrent_seed_stats tss ON tih.info_hash = tss.info_hash " +
            "WHERE t.tid = #{tid}")
    TorrentSeedInfoDTO findTorrentSeedInfoByTid(@Param("tid") Integer tid);
} 